/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.ChargeStartDistanceMapper;
import com.ybkj.daijia.server.mapper.ChargeStartTimeMapper;
import com.ybkj.daijia.server.model.ChargeStartTime;
import com.ybkj.daijia.server.service.ChargeStartTimeService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultChargeStartTimeService implements ChargeStartTimeService {

    @Autowired
    private ChargeStartTimeMapper chargeStartTimeMapper;

    @Autowired
    private ChargeStartDistanceMapper chargeStartDistanceMapper;

    @Transactional(rollbackFor = Exception.class)
    public void delete(ChargeStartTime cst) {

        // 删除时间段关联的收费信息
        chargeStartDistanceMapper.deleteByChargeStartTime(cst.getId());
        // 删除时间段
        chargeStartTimeMapper.deleteByPrimaryKey(cst.getId());

    }

    @Override
    public ChargeStartTime findOne(Long id) {
        return chargeStartTimeMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ChargeStartTime> listAll() {

        return chargeStartTimeMapper.selectAll();
    }

}